/*
 * MIT License
 *
 * Copyright (c) 2020 wen.gu <454727014@qq.com>
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in all
 * copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 */

/***************************************************************************
 * Name: avp_codec.h
 *
 * Purpose: implementation decoder manager  for av player
 *
 * Developer:
 *   wen.gu , 2022-01-19
 *
 * TODO:
 *
 ***************************************************************************/

/******************************************************************************
 **    INCLUDES
 ******************************************************************************/
#ifndef __AVP_CODEC_H__
#define __AVP_CODEC_H__

#include "avp_type.h"
#include "avp_error.h"
#include "avp_media.h"
#include "avp_frame.h"
#include "avp_packet.h"

/******************************************************************************
 **    MACROS
 ******************************************************************************/

/******************************************************************************
 **    TYPE DEFINITIONS
 ******************************************************************************/
G_C_HEADER_START

typedef enum _avp_codec_buf_provide_type
{/** CBP: codec buffer provide */

    AVP_CBP_TYPE_UNKNOWN = 0,
    AVP_CBP_TYPE_INNER_ONLY, /** only support codec inner provide output buffer(frame buffer) */
    AVP_CBP_TYPE_EXTERNAL_ONLY, /** only support external provide output buffer(frame buffer) to codec */
    AVP_CBP_TYPE_ANY,           /** both support inner and external provide output buffer(frame buffer) */
}avp_codec_buf_provide_type_t;

struct _avp_codec;
typedef struct _avp_codec* avp_codec_t;
/******************************************************************************
 **    CLASSES/FUNCTIONS DEFINITIONS
 ******************************************************************************/
G_API GErrc avp_codec_create(avp_codec_t* decoder);
G_API void avp_codec_destroy(avp_codec_t decoder);

G_API GErrc avp_codec_configure(avp_codec_t decoder, const avp_codec_info_t* codec_info);

G_API GErrc avp_codec_start(avp_codec_t decoder);
G_API GErrc avp_codec_pause(avp_codec_t decoder);

G_API GErrc avp_codec_reset(avp_codec_t decoder);

G_API GErrc avp_codec_set_input(avp_codec_t decoder, avp_packet_queue_t pkt_queue);

/**
 * @brief set buffer(frame) queue for decoder output
 * 
 * @param decoder       [in] decoder instance
 * @param empty_queue   [in] the decoder get empty frame buffer to do decodeing(use external buffer to do decodeing )
 * @param output_queue  [in] the decoder output the decoded data
 * @return GErrc success: G_OK, else: error code @see GErrc
 */
G_API GErrc avp_codec_set_output(avp_codec_t decoder, avp_frame_queue_t empty_queue, avp_frame_queue_t output_queue); 


G_API GErrc avp_codec_set_output2(avp_codec_t decoder, GU32 frame_queue_size, avp_frame_queue_t output_queue);

G_API avp_codec_buf_provide_type_t avp_codec_buffer_provide_type(avp_codec_t decoder);


G_C_HEADER_END

#endif /** !__AVP_CODEC_H__ */

